import type PageContent from '@/components/PageContent/index.vue'
import type { IObject, IOperatData } from '@/components/PageContent/types'
import type PageModal from '@/components/PageModal/index.vue'
import type PageSearch from '@/components/PageSearch/index.vue'
export type { IObject, IOperatData }
function usePage() {
    const editModalRef = ref<InstanceType<typeof PageModal>>()
    const searchRef = ref<InstanceType<typeof PageSearch>>()
    const contentRef = ref<InstanceType<typeof PageContent>>()
    const addModalRef = ref<InstanceType<typeof PageModal>>()
    // 搜索
    function handleQueryClick(queryParams: IObject) {
        console.log('handleQueryClick', queryParams)
        // contentRef.value?.fetchPageData(queryParams, true)
        contentRef.value?.fetchPageData()
    }
    // 重置
    function handleResetClick() {
        // contentRef.value?.fetchPageData({}, true)
        contentRef.value?.fetchPageData()
    }
    // 新增
    function handleAddClick() {
        //显示添加表单
        addModalRef.value?.setModalVisible()
    }
    // 导出
    function handleExportClick() {
        // 根据检索条件导出数据
        const queryParams = searchRef.value?.getQueryParams()
        console.log('handleExportClick', queryParams)
        // contentRef.value?.exportPageData(queryParams);
        contentRef.value?.exportPageData()
    }
    // 表单提交
    function handleSubmitClick() {
        //刷新列表数据
        // contentRef.value?.fetchPageData({}, true);
        contentRef.value?.fetchPageData()
    }
    return {
        handleQueryClick,
        handleResetClick,
        handleAddClick,
        handleExportClick,
        handleSubmitClick,
        editModalRef,
    }
}
export default usePage
